import request from '@/utils/request'
import { genParam } from '@/utils/encrypt'

export function getSettings(params) {
  return request({
    url: '/admin/settings/' + params.id + '/info',
    method: 'get'
  })
}

export function editSettings(param) {
  const params = {
    coupon_in_hot_title: param.coupon_in_hot_title,
    coupon_list_title: param.coupon_list_title,
    coupon_intro_in_details: param.coupon_intro_in_details,
    coupon_rebate_in_details: param.coupon_rebate_in_details,
    coupon_wait_for_coupon_list: param.coupon_wait_for_coupon_list,
    coupon_wait_for_coupon_title: param.coupon_wait_for_coupon_title,
    coupon_button: param.coupon_button
  }
  const paramStr = genParam(params)

  return request({
    url: '/admin/settings/' + param.id + '/edit',
    method: 'put',
    data: paramStr
  })
}

export function getInfo(params) {
  return request({
    url: '/admin/system/' + params.id + '/info',
    method: 'get'
  })
}

export function editInfo(param) {
  const params = {
    exchange_rate: param.exchange_rate,
    coupon_expire: param.coupon_expire,
    coupon_bot_rate: param.coupon_bot_rate,
    alibaba_price: param.alibaba_price,
    tbk_rebate_rate: param.tbk_rebate_rate,
    tbk_parent_rate: param.tbk_parent_rate,
    tbk_sub_rate: param.tbk_sub_rate,
    rebate_rate: param.rebate_rate,
    parent_rate: param.parent_rate,
    sub_rate: param.sub_rate,
    title: param.title,
    title_suffix: param.title_suffix,
    keywords: param.keywords,
    description: param.description,
    record: param.record,
    help: param.help,
    advance: param.advance,
    customer_wechat: param.customer_wechat,
    customer_qq: param.customer_qq,
    customer_service: param.customer_service,
    return_protocol: param.return_protocol,
    refund_protocol: param.refund_protocol,
    coupon_protocol: param.coupon_protocol,
    about_us: param.about_us,
    download_Android: param.download_Android,
    download_iOS: param.download_iOS,
    default_post_fee: param.default_post_fee,
    order_info: param.order_info,
    service_rate: param.service_rate,
    registration_agreement: param.registration_agreement,
    cmc_terms_agreement: param.cmc_terms_agreement,
    coupon_introduction: param.coupon_introduction,
    integral_introduction: param.integral_introduction,
    legal_notice: param.legal_notice,
    privacy_agreement: param.privacy_agreement,
    coupon_delay: param.coupon_delay,
    userback:param.userback,
    userwin:param.userwin

  }
  const paramStr = genParam(params)

  return request({
    url: '/admin/system/' + param.id + '/edit',
    method: 'put',
    data: paramStr
  })
}
